package ms.jacrim;

import java.io.File;

import ms.jacrim.pddl.PddlSolution;
import ms.jacrim.pddl.SolutionEvaluatorManager;
import ms.utils.XmlFile;

public class evaluate {

	public static void evaluatePlans(String filename, String xmlModelFile) throws Exception {
		SolutionEvaluatorManager sem = new SolutionEvaluatorManager();
		sem.loadConfig(new XmlFile(xmlModelFile));
		File f = new File(filename);
		if (f.exists()) {
			System.out.printf("Evaluate: %s.\r\n", filename.toUpperCase());
			PddlSolution sol = new PddlSolution(null, filename);
			System.out.printf("Evaluation Value: %f.\r\n", sem.evaluate(sol, true));
			System.out.println();
		}
	}

	/**
	 * @param args
	 * @throws Exception
	 */
	public static void main(String[] args) throws Exception {
		
		if (args.length != 1) {
			System.out.println("Usage: evaluate <solution_file.SOL> <xml_config_file>");
			System.exit(0);
		}
		System.setProperty("java.security.policy", "java.policy");
		String filename = args[0];
		evaluatePlans(filename, args[1]);
	}

}
